package gemini.castor.ui.client.page.widget.categorylist;

import gemini.basic.model.ProductType;

import com.google.gwt.event.shared.GwtEvent;

public class CategoryListEvent extends GwtEvent<CategoryListHandler> {

	private static Type<CategoryListHandler> TYPE;
	
	public static Type<CategoryListHandler> getType() {
		if (TYPE == null)
			TYPE = new Type<CategoryListHandler>();
		return TYPE;
	}
	
	public enum ForwardType {
		SELECT_CATEGORY;
	}
	
	public CategoryListEvent(ForwardType forwardType) {
		super();
		this.setForwardType(forwardType);
	}
	
	private ForwardType forwardType;
	private ProductType selectedCategory;

	@Override
	protected void dispatch(CategoryListHandler handler) {
		if(forwardType.equals(ForwardType.SELECT_CATEGORY)){
			handler.onSelectedCategory(this);
		}
	}
	
	@Override
	public Type<CategoryListHandler> getAssociatedType() {
		return getType();
	}

	public void setForwardType(ForwardType forwardType) {
		this.forwardType = forwardType;
	}

	public ForwardType getForwardType() {
		return forwardType;
	}

	public void setSelectedCategory(ProductType selectedCategory) {
		this.selectedCategory = selectedCategory;
	}

	public ProductType getSelectedCategory() {
		return selectedCategory;
	}
}
